<!-- 一个尝试的通用主从表维护页面 -->
<!--  传入参数 relation=table1-table2:id-foreignId  -->
<%@page contentType="text/html;charset=UTF-8"%>

<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<%
String paramString = request.getParameter("relation");
String priAction = request.getParameter("do");
String defaultV = request.getParameter("default");
String tetherV = request.getParameter("tether");

String[] paras = paramString.split(":");
String primaryTable = "";		//主表表名
String secondaryTable = "";		//从表表名
String primaryKey = "";			//主表主键
String foreignKey = "";			//从表外键
if(paras.length < 2){
	out.println("<h1>传入了错误的参数 传入参数 relation=table1-table2:id-foreignId </h1>");
	return;
}else{
	String[] tabs = paras[0].split("-");
	String[] keys = paras[1].split("-");
	if(tabs.length < 2 ||  keys.length < 2){
		out.println("<h1>传入了错误的参数 传入参数 relation=table1-table2:id-foreignId </h1>");
		return;
	}
	primaryTable = tabs[0];
	secondaryTable = tabs[1];
	primaryKey = keys[0];
	foreignKey = keys[1];
}
if(priAction == null){
	priAction = "primaryDataOperateAction.do";
}
 %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>通用主从表维护页面，主表：<%=primaryTable %>，从表：<%=secondaryTable %></title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="--主从表维护--">
	<meta http-equiv="description" content="This is my page">
  </head>
  <script language="javaScript">
  	function reloadSecondary(tetherId){
  		var url = "cep/easymana.jsp?table=<%=secondaryTable %>&default=<%=foreignKey%>:" + tetherId + "&tether=<%=foreignKey%>:" + tetherId;
  		//alert(url);
  		window.secondary.document.location=url;
  	}
  </script>
  <frameset rows="50%,50%" framespacing="0" frameborder="yes" border="1">
  	<frame bordercolor="0" src="cep/easypri.jsp?table=<%=primaryTable %>&do=<%= priAction%>&default=${param.default}&tether=${param.tether}" name="primary"/>
  	<frame bordercolor="0" src="cep/easymana.jsp?table=<%=secondaryTable %>" name="secondary"/>
  </frameset>
</html>
